home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Run & Stumpy / source / finderevents.cp < prev    next >
Encoding:
Text File  |  1992-06-19  |  1002 b   |  45 lines  |  [TEXT/MPS ]

  1. #define SystemSevenOrLater 1
  2.  
  3. #include <appleevents.h>
  4. #include <aliases.h>
  5. #include <aeregistry.h>
  6.  
  7. #include "aevent.h"
  8. #include "aelist.h"
  9. #include "aeaddress.h"
  10.  
  11. #include "finderevents.h"
  12.  
  13. #define findercreator    'MACS'
  14.  
  15. OSErr tellfindertoopen( const FSSpec& parent, const FSSpec& item )
  16.   {
  17.     AliasHandle alias;
  18.     OSErr error= NewAlias( 0, &item, &alias );
  19.     if (error != noErr)
  20.         return error;
  21.     
  22.     aelist itemlist;
  23.     itemlist.append( typeAlias, (Handle)alias );
  24.     DisposeHandle( (Handle)alias);
  25.     if (itemlist.iswrong())
  26.         return itemlist.whatiswrong();
  27.     
  28.     aeaddress target( findercreator );
  29.     if (target.iswrong())
  30.         return target.whatiswrong();
  31.     
  32.     error= NewAlias( 0, &parent, &alias );
  33.     if (error != noErr)
  34.         return error;
  35.     
  36.     aevent event( kAEFinderEvents, kAEOpenSelection, target );
  37.     event.putparam( keyDirectObject, typeAlias, (Handle)alias );
  38.     event.putparam( keySelection, itemlist );
  39.     DisposeHandle( (Handle)alias );
  40.     if (event.iswrong())
  41.         return event.whatiswrong();
  42.     
  43.     return event.send();
  44.   }
  45.